﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;


public class moneyPouchScript : MonoBehaviour {
	
	public BoxCollider[] pouches;
	public UILabel coinLabel;
	int coinHere;
	List<Vector3> poses;
	public bool selectedCoins;
	public AudioClip coinClang;
	
	// Use this for initialization
	void Start () {
		poses = new List<Vector3>();
		for(int i = 0; i < pouches.Length; i++)
			poses.Add(pouches[i].transform.position);
		
		for(int i = 0; i < pouches.Length; i++)
		{
			int Idx = Random.Range(0,poses.Count);
			pouches[i].transform.position = poses[Idx];
			poses.Remove(poses[Idx]);
		}
		
		coinHere = DataScript.AccessCoin();
		coinLabel.text = string.Format("{0:#,###0}", coinHere);
	}
	
	// Update is called once per frame
	void Update () {
		
	}
	
	public void disableColliders()
	{
		for(int i = 0; i < pouches.Length; i++)
		{
			//Debug.Log("IN");
			//pouches[i].gameObject.GetComponentInChildren<UISprite>().depth = 4;
			pouches[i].enabled = false;
		}
		selectedCoins = true;
		audio.PlayOneShot(coinClang);
	}
	
	public void addMoney(int amount)
	{
		DataScript.SetCoins(DataScript.AccessCoin() + amount);
		coinHere += amount;
		coinLabel.text = string.Format("{0:#,###0}", coinHere);
	}
}
